home *** CD-ROM | disk | FTP | other *** search
/ Micromanía 92 / CDMM92_1.ISO / SOF 2 SDK / sof2sdk-101.msi / _92D6AC311BB48EBA344BBABC89DA6AB0 / _BF2129AD87634FB3A0D0119C0B05C955 < prev    next >
Encoding:
Text File  |  2002-06-05  |  7.0 KB  |  319 lines

  1. // Copyright (C) 2001-2002 Raven Software.
  2. //
  3. // cg_info.c -- display information while data is being loading
  4.  
  5. #include "cg_local.h"
  6.  
  7. #define MAX_LOADING_PLAYER_ICONS    16
  8. #define MAX_LOADING_ITEM_ICONS        26
  9.  
  10. static int            loadingPlayerIconCount;
  11. static int            loadingItemIconCount;
  12. static qhandle_t    loadingPlayerIcons[MAX_LOADING_PLAYER_ICONS];
  13. static qhandle_t    loadingItemIcons[MAX_LOADING_ITEM_ICONS];
  14.  
  15. void CG_LoadBar(void);
  16.  
  17. /*
  18. ======================
  19. CG_LoadingStage
  20. ======================
  21. */
  22. void CG_LoadingStage ( int stage )
  23. {
  24.     if ( !cg.loading )
  25.     {
  26.         return;
  27.     }
  28.  
  29.     cg.loadStage = stage;
  30.  
  31.     if ( cg.loadStage )
  32.     {
  33.         trap_UpdateScreen();
  34.     }
  35. }
  36.  
  37. /*
  38. ======================
  39. CG_LoadingString
  40. ======================
  41. */
  42. void CG_LoadingString( const char *s ) 
  43. {
  44.     if ( !cg.loading )
  45.     {
  46.         return;
  47.     }
  48.  
  49.     Q_strncpyz( cg.infoScreenText, s, sizeof( cg.infoScreenText ) );
  50.  
  51.     trap_UpdateScreen();
  52. }
  53.  
  54. /*
  55. ===================
  56. CG_LoadingItem
  57. ===================
  58. */
  59. void CG_LoadingItem( int itemNum ) 
  60. {
  61.     gitem_t        *item;
  62.  
  63.     if ( !cg.loading )
  64.     {
  65.         return;
  66.     }
  67.  
  68.     item = &bg_itemlist[itemNum];
  69.     
  70.     if ( item->icon && loadingItemIconCount < MAX_LOADING_ITEM_ICONS ) {
  71.         loadingItemIcons[loadingItemIconCount++] = trap_R_RegisterShaderNoMip( item->icon );
  72.     }
  73.  
  74.     CG_LoadingString( item->pickup_name );
  75. }
  76.  
  77. /*
  78. ===================
  79. CG_LoadingClient
  80. ===================
  81. */
  82. void CG_LoadingClient( int clientNum ) 
  83. {
  84.     const char        *info;
  85.     char            personality[MAX_QPATH];
  86.  
  87.     if ( !cg.loading )
  88.     {
  89.         return;
  90.     }
  91.  
  92.     info = CG_ConfigString( CS_PLAYERS + clientNum );
  93.  
  94.     Q_strncpyz( personality, Info_ValueForKey( info, "n" ), sizeof(personality) );
  95.     Q_CleanStr( personality );
  96.  
  97.     CG_LoadingString( personality );
  98. }
  99.  
  100.  
  101. /*
  102. ====================
  103. CG_DrawInformation
  104.  
  105. Draw all the status / pacifier stuff during level loading
  106. ====================
  107. */
  108. void CG_DrawInformation( void ) 
  109. {
  110.     static qhandle_t    levelshot = 0;
  111.     static char            levelshotShader[MAX_QPATH] = "";
  112.  
  113.     const char    *s;
  114.     const char    *info;
  115.     const char    *sysInfo;
  116.     char        shader[MAX_QPATH];
  117.     int            y;
  118.     int            value;
  119.     qhandle_t    overlay;
  120.     char        buf[1024];
  121.  
  122.     // As long as the map change flag is set we draw the map change screen
  123.     if ( cg.mMapChange )
  124.     {
  125.         CG_DrawMapChange ( );
  126.         return;
  127.     }
  128.  
  129.     info = CG_ConfigString( CS_SERVERINFO );
  130.     sysInfo = CG_ConfigString( CS_SYSTEMINFO );
  131.  
  132.     if ( cg.mInRMG )
  133.     {
  134.         const char* terrainInfo;
  135.  
  136.         terrainInfo = CG_ConfigString( CS_TERRAINS + 1 );
  137.         if ( terrainInfo )
  138.         {
  139.             s = Info_ValueForKey ( terrainInfo, "terraindef" );
  140.             Com_sprintf ( shader, sizeof(shader), "gfx/menus/levelshots/mp_rmg_%s", s );
  141.         }
  142.         else
  143.         {
  144.             Com_sprintf ( shader, sizeof(shader), "gfx/menus/levelshots/unknownmap_mp" );
  145.         }
  146.     }
  147.     else
  148.     {
  149.         s = Info_ValueForKey( info, "mapname" );
  150.         Com_sprintf ( shader, sizeof(shader), "gfx/menus/levelshots/%s", s );
  151.     }
  152.  
  153.     if ( Q_stricmp ( levelshotShader, shader ) )
  154.     {
  155.         levelshot = trap_R_RegisterShaderNoMip( shader );
  156.         Com_sprintf ( levelshotShader, sizeof(levelshotShader), shader );
  157.     }
  158.  
  159.     overlay = trap_R_RegisterShaderNoMip( "gfx/menus/levelshots/unknownmap_mp" );    
  160.  
  161.     // Draw the level shot
  162.     trap_R_SetColor( NULL );
  163.  
  164.     if ( levelshot )
  165.     {
  166.         vec4_t fade;
  167.  
  168.         fade[0] = 1.0f;
  169.         fade[1] = 1.0f;
  170.         fade[2] = 1.0f;
  171.         fade[3] = 1.0f - ((float)cg.loadStage / 15.0f);
  172.  
  173.         CG_DrawPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, levelshot );
  174.         
  175.         trap_R_SetColor ( fade );
  176.  
  177.         CG_DrawPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, overlay );
  178.  
  179.         trap_R_SetColor ( NULL );
  180.     }
  181.     else
  182.     {
  183.         CG_DrawPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, overlay );
  184.     }
  185.  
  186.     // Draw the progress bar
  187.     CG_LoadBar();               
  188.  
  189.     // Determine the string to print
  190.     if ( cg.infoScreenText[0] ) 
  191.     {
  192.         s = va("Loading... %s", cg.infoScreenText);
  193.     }
  194.     else
  195.     {
  196.         s = "Awaiting snapshot...";
  197.     }
  198.  
  199.     // Render the string 
  200.     CG_DrawText( 320 - trap_R_GetTextWidth ( s, cgs.media.hudFont, 0.53f, 0 ) / 2, 198 - 32,
  201.                  cgs.media.hudFont, 0.53f, colorWhite, s, 0, 0 );
  202.  
  203.     // draw info string information
  204.  
  205.     y = 250-32;
  206.  
  207.     // don't print server lines if playing a local game
  208.     trap_Cvar_VariableStringBuffer( "sv_running", buf, sizeof( buf ) );
  209.     if ( !atoi( buf ) ) 
  210.     {
  211.         // server hostname
  212.         Q_strncpyz(buf, Info_ValueForKey( info, "sv_hostname" ), 1024);
  213.         Q_CleanStr(buf);
  214.  
  215.         CG_DrawText ( 320 - trap_R_GetTextWidth ( buf, cgs.media.hudFont, 0.53f, 0 ) / 2, y,
  216.                           cgs.media.hudFont, 0.53f, colorWhite, buf, 0, 0 );
  217.  
  218.         y += PROP_HEIGHT;
  219.  
  220.         // pure server
  221.         s = Info_ValueForKey( sysInfo, "sv_pure" );
  222.         if ( atoi(s) ) 
  223.         {
  224.             s = "Pure Server";
  225.             CG_DrawText( 320 - trap_R_GetTextWidth ( s, cgs.media.hudFont, 0.53f, 0 ) / 2, y,
  226.                               cgs.media.hudFont, 0.53f, colorWhite, s, 0, 0 );
  227.  
  228.             y += PROP_HEIGHT;
  229.         }
  230.  
  231.         // server-specific message of the day
  232.         s = CG_ConfigString( CS_MOTD );
  233.         if ( s[0] )         
  234.         {
  235.             CG_DrawText ( 320 - trap_R_GetTextWidth ( s,  cgs.media.hudFont, 0.53f, 0 ) / 2, y,
  236.                               cgs.media.hudFont, 0.53f, colorWhite, s, 0, 0 );
  237.  
  238.             y += PROP_HEIGHT;
  239.         }
  240.  
  241.         // some extra space after hostname and motd
  242.         y += 10;
  243.     }
  244.  
  245.     // map-specific message (long map name)
  246.     s = CG_ConfigString( CS_MESSAGE );
  247.     if ( s[0] ) 
  248.     {
  249.         CG_DrawText ( 320 - trap_R_GetTextWidth ( s, cgs.media.hudFont, 0.53f, 0 ) / 2, y,
  250.                           cgs.media.hudFont, 0.53f, colorWhite, s, 0, 0 );
  251.  
  252.         y += PROP_HEIGHT;
  253.     }
  254.  
  255.     // cheats warning
  256.     s = Info_ValueForKey( sysInfo, "sv_cheats" );
  257.     if ( s[0] == '1' ) 
  258.     {
  259.         s = "CHEATS ARE ENABLED";
  260.         CG_DrawText ( 320 - trap_R_GetTextWidth ( s, cgs.media.hudFont, 0.53f, 0 ) / 2, y,
  261.                           cgs.media.hudFont, 0.53f, colorWhite, s, 0, 0 );
  262.  
  263.         y += PROP_HEIGHT;
  264.  
  265.         cg.cheats = qtrue;
  266.     }
  267.     else
  268.         cg.cheats = qfalse;
  269.  
  270.     s = cgs.gametypeData->displayName;
  271.     CG_DrawText ( 320 - trap_R_GetTextWidth ( s, cgs.media.hudFont, 0.53f, 0 ) / 2, y, 
  272.                       cgs.media.hudFont, 0.53f, colorWhite, s, 0, 0 );
  273.     y += PROP_HEIGHT;
  274.         
  275.     value = atoi( Info_ValueForKey( info, "timelimit" ) );
  276.     if ( value ) 
  277.     {
  278.         s = va( "Timelimit %i", value );
  279.         CG_DrawText ( 320 - trap_R_GetTextWidth( s, cgs.media.hudFont, 0.53f, 0 ) / 2, y,
  280.                           cgs.media.hudFont, 0.53f, colorWhite, s, 0, 0 );
  281.         y += PROP_HEIGHT;
  282.     }
  283.  
  284.     value = atoi( Info_ValueForKey( info, "scorelimit" ) );
  285.     if ( value ) 
  286.     {
  287.         s = va( "Scorelimit %i", value );
  288.         CG_DrawText ( 320 - trap_R_GetTextWidth ( s, cgs.media.hudFont, 0.53f, 0 ) / 2, y, 
  289.                       cgs.media.hudFont, 0.53f, colorWhite, s, 0, 0 );
  290.         y += PROP_HEIGHT;
  291.     }
  292. }
  293.  
  294. /*
  295. ===================
  296. CG_LoadBar
  297. ===================
  298. */
  299.  
  300. #define LOADBAR_CLIP_WIDTH        256
  301. #define LOADBAR_CLIP_HEIGHT        64
  302. #define LOADBAR_BULLET_WIDTH    16
  303. #define LOADBAR_BULLET_HEIGHT    64
  304.  
  305. void CG_LoadBar(void)
  306. {
  307.     int            x,y,i;
  308.  
  309.     y = 50;
  310.     x = (640 - LOADBAR_CLIP_WIDTH) / 2;
  311.  
  312.     for (i=0;i < cg.loadStage; i++ )
  313.     {
  314.         CG_DrawPic(x + (i*LOADBAR_BULLET_WIDTH), y, LOADBAR_BULLET_WIDTH, LOADBAR_BULLET_HEIGHT, cgs.media.loadBulletShader );
  315.     }
  316.  
  317.     CG_DrawPic ( x, y, LOADBAR_CLIP_WIDTH, LOADBAR_CLIP_HEIGHT, cgs.media.loadClipShader );
  318. }
  319.